def nonlinearxy(block):
    """apply a nonlinear function (cubic) to x,y of normalized 
    input data (with -1, 1 cube)"""
    block = _apply_distortion(block)
    return block

_scale=0.1
def _distortion(v):
    "strictly increasing, nonlinear, emphasize outer - a square function"
    sign = 1 if v > 0 else -1
    v = abs(v)
    v2 = sign*float(v*_scale)**2/(_scale**2)
    return v2

def _apply_distortion(block):
    for entry in block:
        entry["x"] = _distortion(entry["x"])
        entry["y"] = _distortion(entry["y"])
    return block


